/**
 * Created by xinxinran on 2018/7/21.
 */
'use strict';
import dictionary from './dictionary';

let _vue, installed = false;

class VueMixin {
    constructor() {
        this.vue = null;
    }

    static install(vue) {
        if (installed && _vue === vue) {
            return;
        }
        installed = true;
        mixinFilters(vue);
    }
}

function mixinFilters(Vue) {
    if (!Vue) {
        return;
    }
    Object.keys(dictionary.status).forEach(key => {
        let statusObj = dictionary.status[key];
        Vue.filter(`${key}Show`, val => {
            return statusObj[val] || val;
        })
    });

    Vue.filter('numberCircleShow', val => {
        return dictionary.numbers[val + ''] || val;
    });
}

export default VueMixin;
